<template>
  <div class="bookbox">
      <el-carousel :interval="6000" type="card" height="200px" >
        <el-carousel-item v-for="(item,index) in books" :key="index" :label="item.bookName">
          <h3 class="medium">
            <img :src="item.bookImg" alt="" @click="detail(item)">
            <span>ssss</span>
          </h3>
        </el-carousel-item>
      </el-carousel>
      <div v-show="isShow" class="book">
        <p class="bookName">{{book.bookName}}</p>
        <p class="bookUser">{{book.bookUser}}</p>
        <el-divider>小说背景</el-divider>
        <span class="bookDescription">{{book.description}}</span>
        <el-divider>正文内容</el-divider>
        <span class="bookContent">{{book.content}}</span>
        <el-divider>翻译</el-divider>
        <span class="bookContentEng">{{book.contentEng}}</span>
      </div>

  </div>
</template>

<script>
import {getBook, list} from "../../api/learn";

export default {
  name: "Book",
  data(){
    return{
      isShow:false,
      books:[],
      book:{}
    }
  },
  mounted() {
    list().then((res)=>{
      this.books=res.data
      console.log(this.books)
    })
    // getBook(1).then((res)=>{
    //   this.books=res.data
    //   console.log(this.books)
    // })
  },
  methods:{
      detail(item){
        this.isShow=true
        this.book=item
      }
  }
}
</script>

<style scoped>
/*.bookbox{*/
/*  max-height: 500px;*/
/*  overflow:auto;*/
/*}*/
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
.book{
  margin-top: 3%;
  text-align: center;
  border: 3px solid white;
  background:#2f2f35;
  border-radius:25px;
  box-shadow: 10px 10px 10px 10px black;
}
.bookName{
  margin-top: 3%;
  color:#2b73af;
  font-size: 30px;
}
.bookUser,.bookContent,.bookDescription,.bookContentEng{
  font-size:10px;
  color:#ccccd6;
}
</style>